=================================================================
MACROS.TXT                                                 1/1/97
=================================================================

ADVANCED MACRO EXPRESSIONS
==========================
Expressions are used to determine values in the {ASSIGN}, {CASE},
{CASE CALL}, {FOR}, {FOR EACH}, {IF}, and {WHILE} commands. See
Advanced Macro Programming Commands for information on these
commands. You can also use expressions to determine values for
Alt-number variables. Expressions can perform operations on
either numbers or strings of text.

An expression can contain as many as 129 keystrokes. A keystroke
can be a character, an extended character, a keystroke command,
or a programming command.

Numeric Expressions
-------------------
The following is a list of numeric expressions. The values must
contain only integers or variables that contain integers. The
highest positive number you should use is 2,147,483,647. Numbers
higher than this are considered to be negative (see Negative
Numbers under Advanced User Information). You can use signed
(+ or -) numbers in expressions.

When performing multiplication or division, only one number may
exceed 65,535. For example, 65536/65535 can be performed, but
65536/65536 cannot.

In the table below, the terms n1 and n2 represent number 1 and
number 2. Although only a single operator is illustrated in each
example, you can use several operators as well as parentheses in
expressions. For definitions of the operations used in this
table, see Expression Terms under Advanced User Information.

Expression  Operation
----------  ---------
!n1         Returns the logical NOT (bitwise) of the number
            n1. Example: !0 is -1.

-n1         Returns the negative of the number n1. Example: If
            variable 1 contains 5, -{VARIABLE}1~ is -5.

n1+n2       Returns the sum of n1 and n2. Example: 5+4 is 9.

n1-n2       Returns the difference of n1 and n2. Example: 10-1
            is 9.

n1*n2       Returns the product of n1 and n2. Example: 6*5 is 30.

n1/n2       Returns the integer quotient of n1 and n2.
            Examples: 20/5 is 4. 5/2 is 2.

n1%n2       Returns the remainder of the quotient of n1 and n2.
            Examples: 20%5 is 0. 5%2 is 1.

n1&n2       Returns the logical AND (bitwise) of n1 and n2.
            Example: If variable 1 contains 5 and variable 2
            contains 10, {VARIABLE}1~=5&{VARIABLE}2~=10 is true
            because both statements are true, but
            {VARIABLE}1~=5&{VARIABLE}2~=5 is false because one
            of the statements is false.

n1|n2       Returns the logical OR (bitwise) of n1 and n2.
            Example: If variable 1 contains 5 and variable 2
            contains 10, {VARIABLE}1~=5|{VARIABLE}2~=3 is true
            because one of the statements is true, but
            {VARIABLE}1~=6|{VARIABLE}2~=3 is false because
            neither of the statements is true.

n1=n2       Returns a true value (-1) if n1 and n2 are equal;
            otherwise, returns a false value (0). Example: If
            variable 1 contains 5, then {VARIABLE}1~=5 is true
            and {VARIABLE}1~=3 is false.

n1!=n2      Returns a true value (-1) if n1 and n2 are not
            equal; otherwise, returns a false value (0).
            Example: If variable 1 holds 5, then {VARIABLE}1~!=3
            is true and {VARIABLE}1~!=5 is false.

n1>n2       Returns a true value (-1) if n1 is greater than n2;
            otherwise, returns a false value (0).
            Examples: 6>4 is true. 4>6 is false.

n1<n2       Returns a true value (-1) if n1 is less than n2;
            otherwise, returns a false value (0).
            Examples: 2<10 is true. 10<2 is false.

If you try to use an invalid numeric expression (for example,
incorrect use of operators, or characters other than numbers and
valid operators), Corel Presentations treats the expression as
text.

String Expressions
------------------
A string is a name for any sequence of one or more characters,
including spaces. For example, "Apple," "245," "QB12," "Z," and
"Personal Computer" are strings. Keyboard commands (for example,
{Enter}, {Bold}) should be enclosed in string delimiters (" or ')
when they are part of an expression.

You must pair delimiters correctly. For example, the delimiters
in "string" and 'string' are paired, but in "string' they are
not. However, one string can use the " character while the other
uses the ' character (for example, "string"='string').

You must use string delimiters whenever you compare two non-
numeric items. If you are comparing the string contents of two
variables, you must enclose both variable commands in string
delimiters. For example, "{VARIABLE}x~"="{VARIABLE}y~".

The expressions outlined below are used to compare strings. The
terms s1 and s2 represent string 1 and string 2.

Expression  Operation
----------  ---------
"s1"="s2"   Returns a true value (-1) if string 1 is identical
            (including case) to string 2; otherwise, returns a
            false value (0). Examples: "true"="true" is true.
            "true"="TRUE" is false.

"s1"!="s2"  Returns a true value (-1) if string 1 is not
            identical (including case) to string 2; otherwise,
            returns a false value (0). Examples: If variable 1
            holds the string "string", then
            "{VARIABLE}1~"!="rope" is true.
            "{VARIABLE}1~"!="string" is false.

"s1">"s2"   Returns a true value (-1) if string 1 is greater than
            string 2; otherwise, returns a false value (0).*
            Examples: "abcd">"aabcd" is true. "a"<"A" is false.

"s1"<"s2"   Returns a true value (-1) if string 1 is less than
            string 2; otherwise, returns a false value (0).*
            Examples: "aabcd"<"abcd" is true. "A">"a" is false.

*In a string comparison, the Corel character set values are
compared. See Corel Character Set Values under Advanced User
Information for details.

If you do not use the delimiters correctly on s1, the expression
is simply treated as text. If you do not use the delimiters
correctly on s2, Corel Presentations considers the expression
to be false.

Expression Evaluation
---------------------
The following information will help you create and use
expressions. You must write expressions according to the rules so
Corel Presentations can evaluate them correctly.

When Corel Presentations encounters an expression in a macro
command, it evaluates the expression first, then uses the result
of the expression to complete the command. For example, in the
statement {ASSIGN}Number~{VARIABLE}Number~+1~, the expression is
"{VARIABLE}Number~+1". When Corel Presentations evaluates the
expression, it increases the contents of the variable by one.
Corel Presentations then replaces the old contents of the
variable with the result of the expression.

In several of the expressions, the result of the operation is
either true (-1) or false (0). Corel Presentations assigns a
numeric value to true and false. These values were chosen because
they are numeric complements of each other. See NOT under
Expression Terms in Advanced User Information.

In the following example, the first assignment statement assigns
false (0) to variable 1, the second assignment statement assigns
true (-1), the complement of false, to variable 1, and the third
assignment statement assigns true (-1) to variable 1.

  {ASSIGN}1~5=4~
  {ASSIGN}1~!{VARIABLE}1~~
  {ASSIGN}1~5!=4~

Operator Precedence
-------------------
Corel Presentations applies operators in an expression in an
order similar to the accepted precedence for mathematical
operators in arithmetic.

The following table shows the order of precedence that Corel
Presentations uses:

  1  - (unary minus), + (unary plus), ! (NOT)
  2  * (multiply), / (divide), % (mod)
  3  - (subtract), + (add)
  4  < (less than), > (greater than), = (equal), != (not equal)
  5  & (AND), | (OR)

You can override the operator precedence by placing parentheses
around those elements that you want evaluated first. Corel
Presentations evaluates elements inside parentheses before it
evaluates the elements outside. If you nest parentheses, Corel
Presentations evaluates the innermost parentheses first.

In the expression 4+7*8, Corel Presentations performs the
multiplication (7*8) first followed by the addition, because
multiplication has a higher precedence than addition. The result
is 60. If you wanted the addition to be performed first, you
would type (4+7)*8. In this case, the result is 88.


ADVANCED USER INFORMATION
=========================

Expression Terms
----------------
The following are technical terms referenced in the discussion of
expressions above. An understanding of these terms is not an
essential part of creating macros. These definitions are provided
for those who are somewhat familiar with programming.

Bitwise Operation
-----------------
In the computer's memory, numbers are represented as a series of
sixteen ones (1) and zeros (0). Each of the 0s and 1s represents
a bit. The pattern for each number is unique. The following table
outlines some values and their corresponding bits:

  Value  Bits
  -----  ----
  0      0000000000000000
  -1     1111111111111111
  -3     1111111111111101
  -21    1111111111101011
  3      0000000000000011
  4      0000000000000100
  7      0000000000000111
  21     0000000000010101
  47     0000000000101111

A bitwise operation works on one column at a time, using a single
bit from each number. The operation is done 16 times so each bit
of each number is operated on.

AND (&)
-------
A bitwise AND operation compares the bits of two numbers. When
both numbers have a 1 bit in the same position (for example,
there is a 1 bit in column 1 (right-most column) of the first
number AND the second number), a 1 is placed in that position
in the result. For example, the expression 21&47 is evaluated
as follows:

  Value  Bits
  -----  ----
  21     0000000000010101
  47     0000000000101111
  21&47  0000000000000101

The resulting bits represent the number 5. So, 21&47=5.

You can use the & operator to specify that two expressions must
be true because -1(true)&-1(true)=-1, but
-1(true)&0(false)=0(false).

NOT (!)
-------
A bitwise NOT operation takes the bits of the number and
complements them. For example, if the expression is !0 (0 is
0000000000000000), the resulting value is -1 (-1 is
1111111111111111).

OR (|)
------
A bitwise OR operation compares the bits of both numbers. When
either number has a 1 bit in the same position (for example,
there is a 1 bit in column 1 (right-most column) of the first
number OR the second number), a 1 is placed in that position in
the result. For example, the expression 21|47 is evaluated as
follows:

  Value  Bits
  -----  ----
  21     0000000000010101
  47     0000000000101111
  21|47  0000000000111111

The resulting bits represent the number 63. So, 21|47=63.

You can use the | operator to specify that at least one of the
two expressions must be true because
-1(true)|0(false)=-1(true), but 0(false)|(0)false=0(false).

Unary operators
---------------
Unary operators apply only to a single operand, as opposed to
binary operators, which work on two operands. For example, the
unary minus in "-2" simply indicates that "2" is negative. Used
as a binary operator in "3-2," the minus sign is now the symbol
for subtraction.

The unary operators are unary minus (-), unary plus (+), and
NOT (!). Unary operators have precedence over binary operators.

Negative Numbers
----------------
In macros, negative numbers are represented as large positive
numbers, from 2,147,483,648 to 4,294,967,295. 4,294,967,295 is
-1, 4,294,967,294 is -2, and so on. To determine the number Corel
Presentations uses to represent any given negative number from -1
to -2,147,483,647, use the following formula:

  4,294,967,296 - |x|

where x is the negative number whose equivalent you are trying to
find. For example, to find the Corel Presentations equivalent of
-3 use this formula:

  4,294,967,296 - 3 = 4,294,967,293

To find the negative number represented by a given Corel
Presentations equivalent, use this formula:

  x - 4,294,967,296

where x is the Corel Presentations equivalent. For example, to
find the negative number represented by 4,294,967,293,

  4,294,967,293 - 4,294,967,296 = -3

You can assign variables to be negative numbers by using the
minus (-) operator, or by using the Corel Presentations
equivalent. Do not use commas or other punctuation in the Corel
Presentations equivalent. For example,

  {ASSIGN}number~-1~

is the same as

  {ASSIGN}number~4294967295~

Corel WordPerfect Character Set Values
--------------------------------------
Corel Presentations assigns a unique value to each character in
each Corel WordPerfect character set, called the Corel
WordPerfect character set value. In a string comparison, the
character set values are compared. See the descriptions for the
{KTON} and {NTOK} commands in Advanced Macro Programming
Commands.

For characters in the same character set, one character is
considered "less than" another character if the first character
comes before the second character. For example, in character
set 0, "3" is less than "4" and "A" is less than "a".

For characters in different character sets, the character from
the character set with the lower numerical value is considered
"less than" the character from the higher numerical character
set. For example, any character from character set 2 is less
than any character from character set 3.


ADVANCED MACRO PROGRAMMING COMMANDS
===================================

The Corel Presentations Programming Language Commands let you
control how macros function. Those familiar with programming will
notice that many Corel Presentations commands are similar to
those in other programming languages.

Command Types
-------------
The programming commands are categorized below by the functions
they perform.

Communicating with the User Interface
{BELL}
{CHAR}
{CONTROL}
{DIALOG}
{DIALOGMSG}
{ENDDIALOG}
{LOOK}
{ORIGINAL KEY}
{PAUSE}
{PAUSE KEY}
{SOUND FILE}
{TEXT}

Directing the Macro
{BREAK}
{CALL}
{CASE}
{CASE CALL}
{CHAIN}
{ELSE}
{END FOR}
{END IF}
{END WHILE}
{FOR}
{FOR EACH}
{GO}
{IF}
{IF EXISTS}
{LABEL}
{NEST}
{NEXT}
{ON CANCEL}
{ON ERROR}
{ON NOT FOUND}
{QUIT}
{RESTART}
{RETURN}
{RETURN CANCEL}
{RETURN ERROR}
{RETURN NOT FOUND}
{SHELL MACRO}
{WHILE}

Stopping Macros or Subroutines
{BREAK}
{QUIT}
{RESTART}
{RETURN}
{RETURN CANCEL}
{RETURN ERROR}
{RETURN NOT FOUND}

Handling the Macro Environment
{CANCEL OFF}
{CANCEL ON}
{ON CANCEL}
{ON ERROR}
{ON NOT FOUND}
{RETURN CANCEL}
{RETURN ERROR}
{RETURN NOT FOUND}

Playing Macros
{ALT letter}
{CHAIN}
{KEY MACRO n}
{NEST}
{SHELL MACRO}
{VAR n}
{VARIABLE}

Using Variables
{ASSIGN}
{CHAR}
{CONTROL}
{DIALOG}
{DIALOGMSG}
{IF}
{IF EXISTS}
{LEN}
{LOOK}
{MID}
{TEXT}
{VAR n}
{VARIABLE}

Using System Variables
{ORIGINAL KEY}
{STATE}
{SYSTEM}

Controlling the Speed or Appearance of Macros
{SPEED}
{STEP 1}
{STEP 10}
{STEP 25}
{WAIT}

Aiding Macro Programming
{;} (Comment)
{BELL}
{SPEED}
{STEP OFF}
{STEP ON}

International Versions
----------------------
If your macros use mnemonics to make menu selections (for
example, n to select No in the Exit Corel Presentations dialog
box), the macros might not work in an international version of
Corel Presentations because the mnemonic for the option may be
different. Use the tips listed below to avoid this problem.

  Yes/No Dialog Boxes
  -------------------
  In a dialog box that has Yes and No buttons, you can use + for
  Yes and - for No.

  System Variables
  ----------------
  If your macros use system variables, use the numeric
  equivalents to the system variable names. The numeric
  equivalents are listed next to each system variable name. See
  {SYSTEM} under Programming Commands.

  Dialog Controls
  ---------------
  If your macros use dialog boxes, use the numeric equivalents to
  the type arguments. The numeric equivalents are listed in the
  explanation of the {CONTROL} command. See {CONTROL} under
  Programming Commands.

Inserting Commands
------------------
For information on how to insert commands, see Macros: Edit in
the Corel Presentations Reference manual.

Command Usage
-------------
Many of the commands use parameters or arguments that require a
tilde (~) at the end. If the tilde is missing, the macro will not
work correctly.

The arguments for each command are displayed in the Macro
Commands list box in the Edit Macro dialog box, and in each
command heading below. In the arguments, var represents a
variable. Expr represents a number, string, variable, command,
or expression (or a combination of these). Additional argument
types are described under each command.

Do not use spaces in any command to separate arguments.


PROGRAMMING COMMANDS
====================

{;}comment~
------------
The text you type between the comment command {;} and the tilde
(~) is ignored when the macro plays. Comments help you identify
what each part of the macro does. You can also use comments to
comment out a section of the macro you don't want to play. This
is useful for testing and debugging your macros. See Commenting
Out under Helps and Hints.

A comment can be one or more lines long. It ends with the first
tilde after the comment command {;}.

Example
The comments in the following example help you to understand what
is happening in the macro.

{ASSIGN}Phrase1~One~
  {;}Assign"One"tovarPhrase1~
{ASSIGN}Phrase2~Two~
  {;}Assign"Two"tovarPhrase2~
{ASSIGN}Concatenation~{VARIABLE}Phrase1~{VARIABLE}Phrase2~~
  {;}AssigntovarConcatenationthecontentsofvarPhrase1
     followedbyvarPhrase2~
dt{Enter}{Enter}
  {;}EntertheTextEditor~
{VARIABLE}Concatenation~
  {;}ExecutevarConcatenation(Typethestring"OneTwo")~

Note that in the Edit Macro dialog box, centered dots ()
represent spaces.

{ASSIGN}var~expr~
-----------------
The {ASSIGN} command evaluates the expr argument and assigns the
value to the variable var. Non-numeric characters and expressions
that Corel Presentations cannot evaluate are treated as text. Do
not enclose expressions in quotes. See Advanced Macro Expressions
for information.

After a value has been assigned to a variable, you can place the
variable command ({VARIABLE}var~) anywhere you would normally
place the variable contents. See Advanced Macro Variables for
more information on variables.

If you want to erase the contents of a variable, leave the expr
argument empty (for example, {ASSIGN}Value1~~). When you empty a
variable, the variable no longer exists. See {IF EXISTS}.

Example
In this example, variable Value1 is first assigned a value, then
an expression, then a string.

{ASSIGN}Value1~3~
  {;}Assign3tovarValue1~
{ASSIGN}Value1~{VARIABLE}Value1~*2~
  {;}MultiplyoldvalueofvarValue1by2,assigntheresult
     (6)asthenew valueofvarValue1~
{ASSIGN}Value1~CorelPresentations~
  {;}Assign"CorelPresentations"stringtovarValue1~

{BELL}
------
The {BELL} command causes your computer to sound a beep. This
command is often useful in combination with the {CHAR} and {TEXT}
commands that prompt the user to enter information. You can also
use it to signal arrival at various points of the macro, such as
at the end of a lengthy process.

Example
In this example, a bell will sound and the text "Hello name."
will be typed at the cursor position. The {BELL} command can also
be placed inside the prompts for {CHAR} and {TEXT} commands (for
example, {TEXT}1~{BELL}Pleaseenteryourname~).

{BELL}
  {;}Soundabell~
{TEXT}Name~Pleaseenteryourname:~
  {;}PromptforanameandplaceitinvarName~
dt{Enter}{Enter}
  {;}Setupatextline~
Hello{VARIABLE}Name~
  {;}Typethemessagewiththenamethatwasentered~

{BREAK}
-------
{BREAK} is useful when you want to skip some commands if the
macro encounters a Cancel or Error condition. Usually it is used
to break out of a loop where several nested IF statements are
used. The location of the command in the file determines its
function.

The rules that govern how this command functions are listed
below. Each of these rules assumes that the previous rules do not
hold true.

1. If a {BREAK} command is encountered within a FOR, FOR EACH,
   or WHILE structure, the macro continues playing at the end
   of the structure (just after the {END FOR} or {END WHILE}).
   If these structures are nested, the macro continues after
   the {END FOR} or {END WHILE} command of the current level.

2. If a {BREAK} command is encountered within an IF structure,
   the macro continues playing at the end of the structure
   (just after the {END IF}). If the IF structures are nested,
   the macro continues after the {END IF} command of the
   current IF structure.

3. If a {BREAK} command is encountered within a subroutine, the
   macro continues playing the calling routine.

4. If a {BREAK} command is encountered in a nested file, the
   macro continues playing the parent file.

5. If none of the above rules holds true and a {BREAK} command
   is encountered, the macro is terminated.

Example
The following macro creates a figure area and retrieves the file
BALLOON.WPG into it. The pointer is then moved to the right and
the process is repeated. After 10 repetitions, the {BREAK}
command breaks out of the IF loop and the macro ends.

{ASSIGN}counter~1~
{ASSIGN}cutoff~10~
  {;}Initializevarcounterandvarcutoff~
df{Goto}x1.25{Tab}1.25{Enter}{Enter}{Enter}{Down}{Down}{Down}
{Down}{Down}{Down}{Down}{Down}{Down}{Down}{Down}{Down}{Right}
{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}
{Right}{Right}
  {;}Positioncursortotopleftcornerofpageanddefine
     figurearea~
{Enter}{Enter}balloon.wpg{Enter}
  {;}RetrievefileBALLOON.WPGintofigurearea~
{Goto}x1.5{Tab}1.5{Enter}{Enter}
  {;}Repositioncursor~
esi{Enter}
  {;}Selectfigure~
{LABEL}Copy~
{IF}{VARIABLE}counter~>{VARIABLE}cutoff~~
{BREAK}
  {;}Ifvarcounterisgreaterthanvarcutoff,breakoutofloop~
{ELSE}
ec
  {;}Copyfigure~
ep
  {;}Pastefigure~
ev
  {;}Movecopyoffigure~
{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}
{Right}{Down}{Down}{Down}{Down}{Down}{Down}{Down}{Down}{Down}
{Down}{Enter}
{ASSIGN}counter~{VARIABLE}counter~+1~
{GO}Copy~
  {;}Otherwise,continuecopying~
{END IF}
{Cancel}
  {;}Deselectobject~
{QUIT}

{CALL}label~
------------
The {CALL} command causes the macro to skip to the label
subroutine. When a {RETURN} is encountered in the subroutine, the
macro continues playing at the command following the {CALL}
command. See Subroutines and Levels under Helps and Hints.

Example
The following example contains a subroutine, Query, that asks if
the user wants to view the current drawing. If so, the macro
plays the View subroutine. If not, the macro continues with the
statement following the {CALL} command.

.
.  (main routine)
.
{CALL}Query~
.
.  (rest of main routine)
.
{QUIT}
  {;}Endthemainroutine~
{LABEL}Query~
  {;}BeginsubroutineQuery~
{CHAR}answer~Doyouwishtoviewthedrawing?(y/n)~
  {;}Promptandassignanswertovaranswer~
{IF}"{VARIABLE}answer~"="y"~
  {;}Ifvaranswerisy...~
{CALL}View~
  {;}CallsubroutineView~
{END IF}
  {;}EndofIFstructure~
{RETURN}
  {;}EndsubroutineQueryandreturntocallingroutine~
{LABEL}View~
  {;}BeginsubroutineView~
{Print}v
  {;}SelectPrint,ViewDrawing~
{RETURN}
  {;}EndsubroutineViewandreturntocallingroutine~

{CANCEL OFF}
------------
The {CANCEL OFF} command is used to stop the Cancel key from
performing its normal function (which usually is to cancel the
macro). You should use this command if you don't want the user
to cancel a certain part of a macro.

Once you have used this command to turn Cancel off, you can press
Ctrl+Break to cancel the macro while it is playing.

{CANCEL ON}
-----------
The {CANCEL ON} command is used to enable the Cancel key after
it has been disabled with the {CANCEL OFF} command (see
{CANCEL OFF}). The Cancel key is enabled, by default,
when you first define a macro.

{CASE}expr~case1~label1~...caseN~labelN~~
-----------------------------------------
The {CASE} command causes different parts of the macro
(designated by label1, label2, and so on) to play, depending on
the value returned by expr. The value returned by expr is
compared to each case (case1, case2, and so on). When a match is
found, the macro branches to the corresponding label. For
example, your macro might ask the user to answer Yes or No to a
prompt. If the answer is Yes, the macro will perform one
function. If the answer is No, the macro will perform another
function.

The value of the expression must match a case exactly. For
example, a value of "y" will match "y" but not "Y". If no match
is found in the {CASE} statement, the macro continues after the
{CASE} statement. You can use an {ELSE} command as the last case
in the command to handle all values that do not match.

It is often helpful to place the {CASE} statement on several
lines so it is more readable. Notice that an extra tilde (~)
is required at the end of the {CASE} statement.

The {CASE} command does not cause the macro to continue playing
with the command following the {CASE} command after the routine
is completed. In other words, it does not call the routine (see
{CALL}); rather, it goes to the routine (see {GO}). If you want
the macro to return, use {CASE CALL}.

Example
In this example, the Error routine is not played unless a
character other than n or y is pressed.

{LABEL}GetChar~
{CHAR}Answer~Continue?(Y/N)~
  {;}AssigncharactertovarAnswer~
{CASE}{VARIABLE}Answer~~
 y~Yes~
 Y~Yes~
 n~No~
 N~No~
  {;}IfvarAnswercontainsyorY,gotolabelYes;ifvar
     AnswercontainsnorN,gotolabelNo.~
{ELSE}~Error~
  {;}Otherwise,gotolabelError.~
~
  {;}BesuretoincludethetildethatendstheCASEstatement.~
{LABEL}Yes~
.
.  (Yes subroutine)
.
{QUIT}
  {;}EndYessubroutine~
{LABEL}No~
.
.  (No subroutine)
.
{QUIT}
  {;}EndNosubroutine~
{LABEL}Error~
.
.     (Error subroutine)
.
{QUIT}
  {;}Endmacro~

{CASE CALL}expr~case1~label1~...caseN~labelN~
---------------------------------------------
The {CASE CALL} command is similar to the {CASE} command. The
only difference is that the macro does not merely go to the
locations indicated by the label arguments. Instead, the label
subroutines are called when a match is made between the value of
the expr argument and a case argument. When the subroutine has
finished, the macro continues playing with the next command after
the {CASE CALL} command.

Example
In the following example, the user is prompted to select a
drawing object. The {CASE CALL} command allows the user to select
the object by number or letter. Once the subroutine corresponding
to the option selected is played, the macro continues with the
{LABEL}Next~ command.

{LABEL}GetDrawingObject~
{CHAR}Object~1Line;2Arrow;3Box:~
  {;}Promptuserfordrawingobject~
{CASE CALL}{VARIABLE}Object~~
 1~Line~
 l~Line~
 L~Line~
  {;}Ifuserenters1,l,orL,callsubroutineLine~
 2~Arrow~
 a~Arrow~
 A~Arrow~
  {;}Ifuserenters2,a,orA,callsubroutineArrow~
 3~Box~
 b~Box~
 B~Box~
  {;}Ifuserenters3,b,orB,callsubroutineBox~
~
  {;}NoticetheextratildetoendtheCASEstatement~
{QUIT}
  {;}Endmainroutine~
{LABEL}Line~
.
.
.
{RETURN}
  {;}Endsubroutine~
{LABEL}Arrow~
.
.
.
{RETURN}
  {;}Endsubroutine~
{LABEL}Box~
.
.
.
{RETURN}
  {;}Endsubroutine~

{CHAIN}macroname~
-----------------
The {CHAIN} command plays the indicated macro when the current
macro is completed regardless of where in the macro the {CHAIN}
command is placed. You can enter a full pathname if you need to
(the .PRM extension is not necessary).

You can chain one macro at each level of nesting. See Levels
under Helps and Hints. If more than one macro is chained at the
current level, only the last macro chained is played when the
current macro is completed.

See Chaining and Nesting under Helps and Hints for more
information on chaining.

Example
The section of the macro between the {LABEL} and {GO} commands
plays repeatedly until {VAR 1} equals 6. When {VAR 1} equals 6,
the original macro ends, and the chained macro, PRINT.PRM, plays.

{CHAIN}Print~
  {;}ExecutethePRINTmacrowhenthismacroiscompleted~
{ASSIGN}1~1~
  {;}Assign1tovar1~
{LABEL}DrawCircle~
  {;}BeginDrawCircleloop~
{IF}{VAR 1}<6~
  {;}Ifvar1islessthan6~
di{Enter}
  {;}SelectDrawCirclefrommenu~
{Right}{Right}{Right}{Right}{Right}{Right}{Right}{Right}
{Right}{Right}{Right}{Enter}
  {;}Drawcircle~
{Right}
  {;}Positioncursorfornextcircle~
{ASSIGN}1~{VAR 1}+1~
  {;}Add1tovar1~
{GO}DrawCircle~
  {;}Gothroughtheloopagain~
{END IF}
  {;}EndtheIFstructure~

{CHAR}var~message~
------------------
This command creates menus and prompts. The {CHAR} command
prompts the user with the message and waits until a single key
is pressed. The key is then assigned to the indicated variable.
See Advanced Macro Variables.

The user can press any key as the input. If Cancel is pressed,
the macro ends unless a {CANCEL OFF} or {ON CANCEL} command has
been played.

Once the key has been assigned to the variable, a {CASE},
{CASE CALL}, or {IF} command can be used to perform different
operations, depending on the key pressed.

Example
In the following example, the user is prompted to select a type
of drawing, after which the {CASE CALL} command calls a
subroutine based on what the user entered.

{CHAR}DrawingType~1Chart;2Text;3DrawingObject;4Bitmap;
 5Presentation:~
  {;}Prompttheuserforinputandassignthekeytovar
     DrawingType~
{CASE CALL}{VARIABLE}DrawType~
 1~Chart~
 2~Text~
 3~Drawing Object~
 4~Bitmap~
 5~Presentation~
~
  {;}CheckvarDrawTypeandbranchtotheappropriatesubroutine~

{CONTROL}type~var~message~x~y~width~
------------------------------------
The {CONTROL} command creates a menu item or button of a
specified type within a dialog box. If the menu item requires
the user to provide some sort of input (such as a number, text,
or filename) or check a box, the user's input is assigned to the
variable var.

The text of the menu item or button is specified by message. The
message can be as many as 255 characters long, and can use any
Corel WordPerfect characters. A mnemonic character in the message
should be preceded by a backslash (\). A real backslash is
indicated by two backslashes (\\).

The x and y values specify the position (in screen coordinates)
of the menu item or button within the dialog box. If you do not
specify an x position, the item uses the same x position as the
previous item; the default position for the first item is two. If
you don't specify a y position, the item is positioned two lines
below the last item (or two lines below the top of the dialog box
for the first item).

The width argument is necessary only for menu items that require
the user to enter text or numbers and specifies how many
characters can be entered in the field. If you do not specify a
width, the entry field is 10 characters long.

All {CONTROL} commands must occur between a {DIALOG} and
{ENDDIALOG} command or they are ignored. You should define menu
items and buttons in the order you want the user to be able to
tab to them.

The table below lists the different types that you can use in
the type argument. Each of the types has an equivalent number
that can be used as the type argument. Specific information about
these types is given in the paragraphs following the dialog box.

  1  ok
  2  cancel
  3  label
  4  option
  5  pushbutton
  6  checkbox
  7  number
  8  text
  9  filename

To create an OK or a Cancel button, insert {CONTROL}OK~ or
{CONTROL}cancel~ without additional arguments. You must list
OK and Cancel buttons after all other {CONTROL} commands in
your dialog box definition. Selecting an OK button returns a 0
to the variable specified in the {DIALOG} command. Selecting a
Cancel button returns a -1 to that variable. See {DIALOG}.

The label type is not an option and cannot be selected. You
should leave the var argument blank when using this type.

Both the option and pushbutton types exit the dialog box when
selected. You should leave the var argument blank when using
these types.

The checkbox type does not exit the dialog box when selected,
unless it is the only option in the dialog box besides OK and
Cancel buttons. You should use a variable with this type. The
variable contains "0" if the box is not checked, and "1" if it
is. You should assign the variable earlier in the macro to
determine whether the box will be checked when the dialog box
is displayed.

The number type does not exit the dialog box when selected,
unless it is the only option in the dialog box besides OK and
Cancel buttons. You should use a variable with this type. The
variable contains the number input by the user.

The text type does not exit the dialog box when selected, unless
it is the only option in the dialog box besides OK and Cancel
buttons. Users can use any Corel WordPerfect characters in the
entry field created by the text type. The amount of text allowed
depends on the width of the entry field (specified in the
{CONTROL} command). You should use a variable with this type to
record the text input by the user.

The filename type is similar to the text type, except that the
user can input IBM ASCII characters only. Also, typing a space
will exit the entry field.

For an example of how to use this command, see {DIALOG}.

{DIALOG}var~title~x~y~width~height~
-----------------------------------
The {DIALOG} command is used to create a dialog box with the
specified title. The definition of a dialog box begins with the
{DIALOG} command and ends with the {ENDDIALOG} command. {CONTROL}
commands between the {DIALOG} and {ENDDIALOG} commands determine
what menu items and buttons appear in the dialog box. See
{CONTROL}. When the user chooses a menu item or button that exits
the dialog box, the number of that menu item or button
(determined by the order of the {CONTROL} commands, not the
number of the option displayed on the dialog box) is assigned to
the variable var, except in the case of Cancel and OK buttons. If
the user chooses an OK button, 0 is assigned to the variable var.
If the user chooses a Cancel button, -1 is assigned to the
variable var. When the user closes the dialog box, the macro
continues with the command following the {ENDDIALOG} command.

The x and y arguments determine the position of the dialog box on
the screen, while the width and height arguments determine the
size. All of these arguments are measured in screen coordinates.
If you do not specify an x position, the dialog box is centered
horizontally; if you do not specify a y position, the dialog box
is centered vertically. If you do not specify the width or
height, Corel Presentations determines the size of the dialog box
based on the contents of the dialog box. You must include the
tildes (~) even if you do not specify a size or position (for
example, {DIALOG}output~DrawingMenu~~~~~).

Example
The macro in the following example creates a dialog box that
helps the user create an invitation. The macro performs different
actions depending on what options the user chooses in the dialog
box.

{ASSIGN}Back~0~
  {;}AssignvarBackavalueof0sothatthecheckboxwillnot
     becheckedwhenthedialogboxopens~
{DIALOG}Output~Invitation~~~40~10~
  {;}Createadialogboxtohelptheusercreateaninvitation.
     Assigntheuser'sselectiontovarOutput~
{CONTROL}checkbox~Back~UseStandardBackground~2~4~~
  {:}Createacheckboxtoallowtheusertochoosewhetherto
     useastandardbackgroundwiththeinvitation.~
{CONTROL}option~~UseCustomizedText~2~6~~
  {:}Createanoptionthatallowstheusertowritethetextof
     theinvitation~
{CONTROL}option~~FillInForm~2~8~~
  {;}Createanoptionthatallowstheusertouseapre-defined
     formfortheinvitation~
{CONTROL}ok~
  {;}CreateanOKbutton~
{CONTROL}cancel~
  {;}CreateaCancelbutton~
{ENDDIALOG}
  {;}Endofdialogboxdefinition~
{CASE CALL}{VARIABLE}Output~~
  {;}ThevarOutputwillneverequal1becausethefirstoption
     (thecheckbox)doesnotclosethedialogboxandthelast
     optionchosen(theonethatclosesthedialog),istheone
     savedinthevarOutput~
 2~Continue~
  {;}Iftheuserchosesoption2(UseCustomizedText),callthe
     Continuelabel~
 3~Continue~
  {;}Iftheuserchosesoption3(FillInForm),callthe
     Continuelabel~
 0~Quit~
  {;}IftheuserchosesOK,calltheQuitlabel~
 -1~Reset~
  {;}IftheuserchosesCancel,calltheResetlabel.The
     subroutineatthislabelresetsthevalueofvarBackto0
     (uncheckstheboxincaseitwaschecked),thenendsthe
     macro~
~
  {;}BesuretoincludethetildethatendstheCASECALL
     statement~
{QUIT}
{LABEL}Continue~
{IF}{VARIABLE}Back~=1~
  {;}Iftheusercheckedtheboxtousethestandardbackground~
{Retrieve}bkgrnd-1.wpg{Enter}
  {;}Retrievethefilebkgrnd-1.wpg~
{END IF}
  {;}EndofIFstructure~
{IF}{VARIABLE}Output~=2~
  {;}Iftheuserchoseoption2(UseCustomizedText)~
{GO}Custom~
  {;}GototheCustomlabel~
{ELSE}
  {;}Otherwise~
{GO}Form~
  {;}GototheFormlabel~
{END IF}
  {;}EndofIFstructure~
{RETURN}
{LABEL}Custom~
.
.  (Subroutine to create a custom invitation)
.
{LABEL}Form~
.
.  (Subroutine to use pre-defined form for the invitation)
.

{DIALOGMSG}message~
-------------------
The {DIALOGMSG} command is used to create a dialog box that
contains the text of message and a Continue button.

Example
In the following example, a message dialog box appears if the
user chooses an invalid option.

{LABEL}start~
  {;}Beginningofthesubroutineinwhichtheuserchoosesan
     option~
.
.  (subroutine including a CASE statement)
.
{ELSE}~Message~
  {;}Ifthesituationdoesn'tmatchanyofthecaseslisted
     above,calltheMessagelabel~
{LABEL}Message~
{DIALOGMSG}Theselectedoptionisunavailable.Tryagain.~
  {;}Displayamessagedialogbox~
{GO}start~
  {;}Beginthesubroutineagain~
.
.
.

{ELSE}
------
The {ELSE} command is used with the {IF}, {IF EXISTS}, {END IF},
{CASE}, and {CASE CALL} commands. It marks the beginning of the
commands that play when the IF value is false (zero) or when none
of the cases match. See {IF} and {CASE}.

It often helps to think of {ELSE} as the word "otherwise." The
{ELSE} command is not a required part of an IF or CASE statement.
It should be used when there are certain steps that need to play
only when the IF value is false (zero) or when none of the cases
match. The commands below {END IF} play regardless of whether the
IF value is true.

Example
In the example below, if the variable Number contains a negative
number, the macro adds 2 to Number. Otherwise, it subtracts 2.

{IF}{VARIABLE}Number~<0~
  {;}IfvarNumberislessthan0~
{ASSIGN}Number~{VARIABLE}Number~+2~
  {;}Add2tovarNumber~
{ELSE}
  {;}Otherwise~
{ASSIGN}Number~{VARIABLE}Number~-2~
  {;}Subtract2fromvarNumber~
{END IF}
  {;}Endof{IF}statement~

{ENDDIALOG}
-----------
This command signals the end of a dialog box definition and must
be paired with a {DIALOG} command. For an example of how to use
this command, see {DIALOG}.

{END FOR}
---------
This command signals the end of a {FOR} or {FOR EACH} loop. For
examples of how to use this command, see {FOR} and {FOR EACH}.

{END IF}
--------
This command signals the end of an IF structure and is used with
the {IF} and {IF EXISTS} commands. See {CALL} and {IF} for
examples of how to use this command.

{END WHILE}
-----------
This command signals the end of a {WHILE} loop. For an example of
how to use this command, see {WHILE}.

{FOR}var~start~stop~step~
-------------------------
The {FOR} command is useful for repeating a series of commands a
certain number of times. The first time the {FOR} command is
encountered, it assigns the variable the start value. When the
{END FOR} command is reached, the macro returns to the {FOR}
command and the variable is increased by the step value. This
process continues, repeatedly playing all the commands between
the {FOR} and {END FOR} commands, until the variable reaches the
stop value.

The start, stop, and step values can be entered in the command
as expressions, variables, or other commands. Each expression,
variable, or command is evaluated, then the value is assigned to
the variable.

In any FOR loop, the {END FOR} command must be used to determine
the end of the series of commands included in the loop. You can
also use the {NEXT} command to begin the next time through the
loop, but you must still include an {END FOR} to mark the end of
the loop. See {NEXT}.

Example
The following example shows how you could use the {FOR} command
to move the cursor 10 times to the left.

{FOR}Counter~1~10~1~
  {;}ForeveryvalueofCounterbetween1and10(values
     incrementedby1eachtimethroughtheloop)~
{Left}
  {;}Movecursortotheleft~
{END FOR}
  {;}Endof{FOR}loop.IncrementCounterandrepeattheloop
     unlessCounter>=10~

{FOR EACH}var~expr1~...exprN~~
------------------------------
The {FOR EACH} command is similar to the {FOR} command. The
difference is that instead of having a sequential step value,
each value that you want to assign to the variable is included
as an argument in the command. These values do not need to be
in numerical order. (The values can still be included as
expressions, variables, or commands. They are evaluated before
being assigned to the variable.) See {FOR} for more information.

Like the {FOR} command, the {FOR EACH} command itself assigns the
variable the start value. You do not need to pre-assign the
variable. Each time the {FOR EACH} command plays (at the top of
the loop), the variable is assigned the next value.

Remember to end the loop with an {END FOR} command.

Example
In the following example, the macro will loop 5 times. Each time
it loops, the variable "Count" will be equal to the specified
value (that is, Count=15 on the first loop, Count=10 on the
second loop, Count=25 on the third loop, and so on).

dt{Enter}{Enter}
  {;}Begintextline~
{FOR EACH}Count~15~10~25~95~50~~
  {;}VarCountisinitializedto15thefirsttimethroughthe
     loop,then10,then25,andsoon~
{VARIABLE}Count~
  {;}WriteoutvarCountfollowedbyaspace~
{END FOR}
  {;}PlaytheloopagainunlessCount=50.Inthatcase,end
     theloop.~

When the macro is complete, "15 10 25 95 50 " will have been
written out. The space (represented by "") after the
{VARIABLE}Count~ command causes a space to be left after each
number when the numbers are written out.

{GO}label~
----------
The {GO} command causes a different part of the macro file to
play. It is used with the {LABEL} command, which marks the point
where the macro should continue to play.

The {GO} command is useful when you want to skip a part of your
macro, or to transfer control to another part based on a
condition. Unlike the {CALL} command, {GO} does not return to
the command immediately following the {CALL} command.

Example
This macro checks to see if the Print command has been entered in
variable 1. Notice that the steps between {END IF} and {LABEL}
are skipped if variable 1 contains {Print}. The macro ends when
the Print routine finishes.

{IF}"{VARIABLE}1~"="{Print}"~
  {;}Ifvar1contains{Print}~
{GO}Print~
  {;}GotothePrintlabel~
{END IF}
.
.  (middle section of macro)
.
{LABEL}Print~
.
.  (Steps of the Print subroutine)
.
{QUIT}
  {;}Stopmacro~

{IF}expr~
---------
The {IF} command is used to play a set of commands only if a
certain condition exists. If the condition exists (expr is
evaluated to be true), the commands directly after the {IF}
command are played. If the condition does not exist (expr is
evaluated to be false), the commands directly after the {END IF}
command are played.

The expr argument is usually a logical expression. Any relational
operator (such as, =, !=, >) may be used. An expression is true
if it is evaluated as a non-zero number. For example, the
expression 4=4 is true (which corresponds to -1). A false value
is equivalent to 0 or no result. Text values and commands must be
enclosed in quotes to be evaluated correctly. See Advanced Macro
Expressions for more information on evaluating expressions.

If the value is true, the commands directly after the {IF} play.
If the value is false (or there is no value at all), the commands
directly after {IF} are skipped, and the macro continues playing
after the {ELSE} or {END IF} command, whichever comes first.

An {IF} statement always begins with {IF} and ends with {END IF}.
If you want certain commands to play only when the value is not
true, use the {ELSE} command (see {ELSE}).

It is also possible to nest {IF} commands. Both the {IF} and
{END IF} commands of the nested IF must be contained inside the
{IF} and {END IF} commands of the primary IF.

Example
In the example below, the Setup menu is displayed only if the
appropriate password is in variable Input.

{ASSIGN}Password~present~
{TEXT}Input~Enteryourpassword:~
{IF}"{VARIABLE}Input~"="{VARIABLE}Password~"~
  {;}IfvarInputcontainsthepassword(asstoredinvar
     Password)~
{Setup}
  {;}EntertheSetupmenu~
{END IF}
  {;}Endof{IF}structure~

Notice that quotes are placed around both {VARIABLE}Input~ and
{VARIABLE}Password~ because it is a text comparison. If it were a
numeric comparison, quote marks would not be used.

{IF EXISTS}var~
---------------
The {IF EXISTS} command checks to see if the indicated variable
has been assigned a value. If it has, the commands following
{IF EXISTS} play. If not, the macro continues playing after the
{ELSE} or {END IF} command, whichever comes first. Like other IF
statements, the {IF EXISTS} command requires an {END IF} and can
use an {ELSE}. See {IF}.

Common uses for the {IF EXISTS} command include establishing a
default response at a menu. {IF EXISTS} is also useful when you
want the macro to pause until a key is pressed. See {LOOK}.

Example
The following example shows how you can use the {IF EXISTS}
command to set up a default response to a user prompt:

{TEXT}Object~1Rectangle;2Line;3Arrow:1{Left}~
  {;}Userselectsobject~
{IF EXISTS}Object~
{ELSE}
  {;}IfuserpressedEnteratmenu~
{ASSIGN}Object~1~
  {;}Usedefaultof"1"~
{END IF}

{KTON}key~
----------
The {KTON} (Key To Number) command converts key (which may be any
key on the keyboard) to a unique number, its Corel Presentations
"key value." {KTON} performs the opposite function of the {NTOK}
command (see {NTOK}).

If you take the {KTON} of a function key, an editing key, or a
cursor movement key, the key value is the end result. This is the
value you would use with the {NTOK} command.

If key is a character, you can use the key value to calculate the
Corel WordPerfect character set value. The character set value
can be assigned to a variable, and a variable can be used to
input the character set value.

To calculate the character set value for a given key, use the
{KTON} command to obtain the key value, then divide the key value
by 256.

The quotient is the number of the Corel WordPerfect character set
(0-12). The remainder is the character number in the character
set (0-255).

Example
For example, if you want your macro to calculate the character
set value for a character, you could use the following macro:

{CHAR}Key~Typeanycharacter~
  {;}AssigninputtovarKey~
{ASSIGN}Set~{KTON}{VARIABLE}Key~~/256~
  {;}AssignquotienttovarSet~
dt{Enter}{Enter}
  {;}Begintextline~
{ASSIGN}Num~{KTON}{VARIABLE}Key~~%256~
  {;}AssignremaindertovarNum~
{VARIABLE}Set~,{VARIABLE}Num~
  {;}Writeoutcharactersetvalue~

This macro prompts for a key, then calculates and writes out the
character set value for that key.

{LABEL}label~
-------------
A {LABEL} command marks a place in the macro file. The {CALL},
{CASE}, {CASE CALL}, and {GO} commands cause the macro to
continue playing at the label.

You can also use the {LABEL} command with the {RETURN} command
to create subroutines. See Subroutines under Helps and Hints.

The label name distinguishes each label from the others. Label
names have no restrictions regarding length; however, the macro
recognizes only the first 15 characters. In other words, Corel
Presentations considers ABCDEFGHIJKLMNO (15 characters) and
ABCDEFGHIJKLMNOP (16 characters) to be the same label name, but
considers ABCDEFGHIJKLMN (14 characters) and ABCDEFGHIJKLMNO
(15 characters) to be different label names. The only character
you cannot use in the label name is a tilde (~), because a tilde
ends the label name. You can use spaces.

There can be many labels in the same macro file as long as each
one has a different name. If the name is duplicated, the first
one is used. The other is ignored.

See {CALL} and {LOOK} for examples of how to use this command.

{LEN}var~
---------
This command determines the length of the contents of a variable.
It is useful for validating or restricting the length of user
input.

Example
In this example, if the user enters more than two letters at the
{TEXT} prompt, the macro rejects it and the user is prompted
again.

{LABEL}GetState~
{TEXT}State~Enteratwo-letterstateabbreviation:~
{IF}{LEN}State~>2~
{GO}GetState~
{END IF}

{LOOK}var~
----------
The {LOOK} command checks to see if the user has pressed a key.
If a key has been pressed, it is assigned to the variable; the
keystroke action is not performed. If a key has not been pressed,
the contents of the variable are deleted and the macro continues.

Example
In the following example, {LOOK} is used to simulate a pause that
does not end with the Enter key. See {PAUSE}. (You could also do
this with the {PAUSE KEY} command.)

{LABEL}Loop~
  {;}Topoftheloop~
{LOOK}Key~
  (;}Checktoseeifakeywaspressed~
{IF}"{VARIABLE}Key~"="{Exit}"~
  {;}IfExitwaspressed~
{GO}Next~
  {;}dropoutoftheloop~
{END IF}
  {;}Endof{IF}structure~
{VARIABLE}Key~
  {;}Performthekeystroke~
{GO}Loop~
  {;}Gotothetopoftheloop~
{LABEL}Next~
.
.
.

{MID}var~offset~count~
----------------------
Use this command to return part of the string contained in the
variable var. The substring that is returned begins offset
characters from the beginning of the string and continues for
count characters. If you want to return the first character of
the string, enter "0" as the offset value.

This command is often used with {LEN} to return only the integer
portion of non-integer numbers.

Example
The following macro creates a text area and then separates the
words "Corel Presentations" into two substrings and writes them
to the text area.

{ASSIGN}Name~CorelPresentations~
  {;}Assign"CorelPresentations"tovarName~
dt{Enter}{Enter}
  {;}Createtextline~
{ASSIGN}FirstName~{MID}Name~0~5~~
  {;}Returnsubstring"Corel"andplaceinvarFirstName~
{ASSIGN}LastName~{MID}Name~6~13~~
  {;}Returnsubstring"Presentations"andplaceinvarLastName~
{VARIABLE}FirstName~{Enter}
{VARIABLE}LastName~{Enter}
{Exit}

{NEST}macroname~
----------------
The {NEST} macro command plays another macro. When the nested
macro has finished, the parent macro continues playing. It is
somewhat like placing the contents of the specified macro where
the {NEST} command is. See Chaining and Nesting under Helps and
Hints for more information on nesting.

Example
In the following example, a macro that saves the drawing on the
screen is nested within another macro.

{IF}{VAR 0}!=0~
  {;}Ifvar0isnon-zero,savethepage~
{NEST}SavePage~
  {;}NesttheSAVEPAGE.PRMmacro~
{END IF}
  {;}EndofIFstructure~

{NEXT}
------
Use this command to move to the next time through a {FOR},
{FOR EACH}, or {WHILE} loop. Usually, the {END FOR} or
{END WHILE} command that ends the loop starts the next repetition
of the loop. However, the {NEXT} command can be used to repeat
the loop from other than the end of the loop. For example, you
may use nested IF statements as part of the loop. When a certain
condition is true, you would use the {NEXT} command to abandon
the rest of the commands in the loop and move to the top of the
loop.

Even if you use the {NEXT} command in a loop, you must still use
an {END FOR} or {END WHILE} command to mark the end of the loop.

Example
The following macro creates a text area and then writes each
letter of the alphabet, skipping the letters "C," "F," and "W."

{Home}{Left}{Right}{Right}{Right}{Right}{Right}
  {;}Positioncursoratleftedgeofwindow~
dt{Enter}{Enter}
  {;}Begintextline~
{ASSIGN}Letter~64~
  {;}InitializevarLetterto64~
{WHILE}{VARIABLE}Letter~<90~
{ASSIGN}letter~{VARIABLE}Letter~+1~
  {;}IncreasevalueofvarLetterby1~
{IF}{VARIABLE}Letter~=67~
{NEXT}
  {;}SkipifLetteris67("C")~
{ELSE}
  {IF}{VARIABLE}Letter~=70~
  {NEXT}
    {;}SkipifLetteris70("F")~
  {ELSE}
    {IF}{VARIABLE}Letter~=87~
    {NEXT}
      {;}SkipifLetteris87("W")~
    {END IF}
  {END IF}
{END IF}
{NTOK}{VARIABLE}Letter~~
{END WHILE}
{Exit}

{NTOK}number~
-------------
The {NTOK} (Number To Key) command converts a Corel Presentations
key value to its character or function equivalent. It performs
the opposite function of the {KTON} command (see {KTON}).

For example, if you take the {NTOK} of 32809 (Save), a Save is
performed. If you take the {NTOK} of 1537, a "" is written out.

You can also take the {NTOK} of a Corel WordPerfect character set
value. For example, the character set value for  is 6,1. Type
{NTOK}6,1~ to obtain .

If you want to calculate the key value for a given character set
value, multiply the character set number by 256, then add the
number of the character.

You can then use the {NTOK} command to obtain the character.

For example, "" is character number 1 in character set 6.
Multiply 256 times 6 (1536), then add 1 (1537). You can then
take the {NTOK} of 1537 to obtain .

Example
The following example prompts for a number, then returns the
character or function equivalent.

{TEXT}Num~Typeanumber:~
{NTOK}{VARIABLE}Num~~

If the number returns a function, such as Save, and you do not
want to perform the function, you can store it in a variable
(for example, {ASSIGN}Key~{NTOK}{VARIABLE}Num~~~).

{ON CANCEL}action~
------------------
The {ON CANCEL} command tells Corel Presentations what to do if a
user presses Cancel (Esc) or if a {RETURN CANCEL} command has
been returned by a subroutine or nested macro. When a Cancel
occurs, Corel Presentations will know what to do next only if it
has already encountered the {ON CANCEL} command. For this reason,
it is necessary to place the command before a Cancel can occur;
otherwise, the macro will be canceled when it encounters a Cancel
command.

The valid actions available with this command are:

{BREAK}
{CALL}
{GO}
{QUIT}
{RESTART}
{RETURN}
{RETURN CANCEL}

Since {GO} and {CALL} require a tilde (~) after the label, there
must be two tilde marks (~~) at the end of either of these
commands (for example, {ON CANCEL}{GO}label~~).

If the user presses Cancel (Esc) and no {ON CANCEL} command has
been encountered, the macro ends.

If no action is specified in the command (for example,
{ON CANCEL}~) and the user presses Cancel (Esc) or the macro
encounters a {RETURN CANCEL} command, the macro continues as
if there had been no cancel. In addition, if the user presses
Cancel, the keystroke is ignored. In other words, a {LOOK} or
{ORIGINAL KEY} command will not detect that the Cancel key was
pressed. If you want the Cancel key to be used as input, use
the {CANCEL OFF} command before requesting the input.

When the user presses Cancel or the macro encounters a
{RETURN CANCEL}, Corel Presentations performs the action
specified by the last {ON CANCEL} command encountered at the
current level. See Levels under Helps and Hints. If the current
level contains no {ON CANCEL} command, Corel Presentations looks
to successively higher levels and performs the action specified
by the last {ON CANCEL} command. If no {ON CANCEL} is
encountered, the macro ends.

If you chain or nest a macro, the {ON CANCEL} command is not
passed from the parent file to the nested or chained file.
Rather, Cancel performs its regular function (stopping the macro)
until another {ON CANCEL} command is encountered.

When the lower level finishes and the higher level continues, the
last {ON CANCEL} command encountered at the higher level resumes
effect.

Example
In the following example, if the user presses Cancel (Esc) during
the macro, the routine End is played.

{ON CANCEL}{GO}End~~
.
.  (commands in macro)
.
{LABEL}End~
  {;}BeginningofEndroutine~
{DIALOGMSG}Macrocanceledprematurely.~
  {;}Sendnotificationmessage~
{QUIT}
  {;}Endthemacro~
.
.  (rest of macro)
.

{ON ERROR}action~
-----------------
The {ON ERROR} command tells Corel Presentations what to do if an
error is detected in the macro, if an error is returned by Corel
Presentations or DOS, or if a {RETURN ERROR} command is
encountered in a subroutine or nested macro.

For a list of actions that are available with this command, see
{ON CANCEL}.

Inserting this command without an action ({ON ERROR}~) will cause
Corel Presentations to ignore the error and continue playing
(when possible).

If you use the {ON ERROR} command, the user will not see any
error message to or from Corel Presentations. Instead, the action
specified in the {ON ERROR} command will occur.

If you chain a file that does not exist or is not found, the
error condition is not generated until the macro tries to play
the chained file (for example, at the end of the current macro).
See Chaining and Nesting under Helps and Hints, and the
descriptions for the {CHAIN} command for more information.

If an error is encountered and {ON ERROR} exists, the error is
sent to the next higher level in the macro.

The range of effect of the {ON ERROR} command is the same as the
{ON CANCEL} command. See {ON CANCEL}.

Example
In the following example, the macro requests that the user enter
the name of a file. The macro then tries to retrieve it. The
{ON ERROR} command specifies that the Error routine be played if
the file is not found when the macro tries to retrieve it.

{ON ERROR}{GO}Error~~
  {;}Ifanerrorisgenerated,playtheErrorroutine~
{LABEL}GetFile~
{TEXT}Filename~Filetoberetrieved:~
  {;}Promptuserforfile~
{Retrieve}{VARIABLE}Filename~{Enter}
  {;}Retrievethefile~
.
.  (more commands)
.
{LABEL}Error~
  {;}Ifthefilewasnotfoundwhenthemacrotriedto
     retrieveit,themacrocontinueshere~
{Cancel}
  {;}Cancel"Drawingtoberetrieved:"prompt~
{DIALOGMSG}Thefileyouenteredisnotinthedefaultdirectory
 (orthedirectory youspecified).Tryagain.~
  {;}Telltheuserwhathappened~
{GO}GetFile~
  {;}Promptagainforthefile~

{ON NOT FOUND}action~
---------------------
The {ON NOT FOUND} command tells Corel Presentations what to do
if a search fails or a {RETURN NOT FOUND} is returned by a
nested macro or subroutine. If no {ON NOT FOUND} command is
included before a Not Found condition occurs, the Not Found
cancels the macro.

For a list of actions that are available with this command, see
{ON CANCEL}.

If you search for a nonexistent name with the Name Search
feature, the Not Found condition is returned at the first
character that does not match. You should insert an {Enter}
command somewhere in the macro after the Not Found is generated
to end the name search.

If during a name search all characters before the {Enter} match,
a Not Found is not generated, even though there may be additional
characters in the highlighted name. To check whether the name is
an exact match, use {HPg} (Ctrl-Enter) instead of {Enter} to end
the Name Search. When you use {HPg}, a Not Found is generated if
the filename does not match exactly.

Example
In this example, the {ON NOT FOUND}{BREAK}~ command prevents the
macro from ending when the search fails. Instead, the macro
continues with the command directly below the {IF} structure.

{CHAR}Continue~Continue?1Yes;2No:~
{ON NOT FOUND}{BREAK}~
  {;}Ifsearchfails,breaktotheendofthe{IF}structure~
{IF}{VARIABLE}Continue~=1~
  {;}IfvarContinuecontains1(continue)~
{Home}{Home}{Up}
  {;}Movetothetopofthetextarea~
{Search}test{Search}
  {;}Searchfor"test"~
{Backspace}{Backspace}{Backspace}{Backspace}{Backspace}
  {;}Deletetheword~
{END IF}
  {;}Endof{IF}structure~
{TEXT}var~Done.~{PAUSE}

{ORIGINAL KEY}
--------------
The {ORIGINAL KEY} macro command evaluates the original
(unmapped) action of the last key entered from the keyboard. The
last key pressed could be either a key that was read before the
macro started (usually the key that started the macro) or a
character input with a {CHAR}, {LOOK}, {TEXT}, {PAUSE}, or
{PAUSE KEY} command.

Example
For example, you might want your macro to check whether a user
has typed a specific key, regardless of the keyboard definition.
If you want to exit if F7 has been pressed, use the following
macro:

{LOOK}Key~
  {;}Checktoseeifakeyhasbeenpressed.Assignittovar
     Key~
{IF}"{ORIGINAL KEY}"="{Exit}"~
  {;}IftheunmappedkeyisExit~
{Exit}
  {;}Exit~
{END IF}
  {;}Endof{IF}statement~

{PAUSE}
-------
The {PAUSE} command causes the macro to pause while the user
edits or types new text. The macro continues after the user
presses Enter. If you want another key to end the pause, see
{PAUSE KEY}.

Because {PAUSE} does not prompt the user, the {BELL} command is
often used with {PAUSE}. See Prompting and User Input under Helps
and Hints for other methods of obtaining user input.

Example
The following example assumes the user is in the Text Editor.
After the {TEXT} command is performed, the user can do any
editing. The macro continues when the user presses Enter.

{TEXT}var~Editthetext.PressEnterwhendone.~
  {;}Sendaprompttothescreen~
{PAUSE}
  {;}Pauseforusertoedittext~

{PAUSE KEY}key~
---------------
This command functions like the {PAUSE} command, except that
you specify the key that ends the pause. See {PAUSE}.

Example
If you wanted Exit (F7) to end the pause, you could use the
following commands:

{TEXT}var~Editthedrawing.PressExitwhendone.~
  {;}Sendmessagetouser.~
{PAUSE KEY}{Exit}~
  {;}Stopsothatusercanedittext.Themacrocontinues
     whentheuserpressesExit(F7)~

{QUIT}
------
The {QUIT} command stops the macro.

See {CASE} and {GO} for examples of how to use this command.

{RESTART}
---------
The {RESTART} command ends the parent macro when the current
nested macro ends. This command can be used if you do not want
a macro to return to the macro from which it was nested. The
{RESTART} command can be inserted anywhere in the nested macro.
The macro "remembers" the {RESTART} command and performs it after
all other commands have been performed.

Example
In the following example, the parent macro nests the macro
CONTINUE.PRM, which asks the user whether he or she wants to
continue or stop. If the user elects to continue, the parent
file continues playing. If the user elects to stop, the {RESTART}
command prevents the parent file from continuing after the last
command of the nested file.

Parent File:
.
.
.
{NEST}Continue~
.
.
.

Nested File (CONTINUE.PRM):
{CHAR}Answer~1Continue;2Stop:1{Left}~
  {;}Promptuser~
{IF}{VARIABLE}Answer~=1~
  {;}Ifuserelectstocontinue...~
{RETURN}
  {;}...returntotheparentfile.~
{ELSE}
  {;}Otherwise...~
{RESTART}
  {;}...endthemacroattheendofthisfile.~
{END IF}
  {;}EndofIFstatement~
{TEXT}var~Youhaveelectedtostopthemacro.PressEnterto
 end.~
  {;}Promptuser~
{PAUSE}
  {;}WaitforusertopressEnter~

{RETURN}
--------
The {RETURN} command marks the end of a subroutine and signals
the macro to return from a {CALL} or {CASE CALL} command.

If there is no {CALL} or {CASE CALL} to return to and the macro
file containing this command is nested, {RETURN} signals the
macro to return to the file from which it was nested. If the
command is not in a nested file and there is no {CALL} or
{CASE CALL} to return to, {RETURN} marks the end of a macro.
See {CALL} and {RESTART} for examples of how to use this command.

{RETURN CANCEL}
---------------
The {RETURN CANCEL} command causes the macro to stop playing
the current level and sends a Cancel to the next higher level.
See Levels under Helps and Hints.

Since {RETURN CANCEL} is the default action for Cancel when no
{ON CANCEL} command is used, the {RETURN CANCEL} command is most
often used to set the {ON CANCEL} action back to the default
after it has been changed.

Example
In this example, {RETURN CANCEL} is used to set the {ON CANCEL}
action to {RETURN CANCEL}.

{ONCANCEL}{GO}SendMessage~~
.
.  (During this part of the macro, if the user presses Cancel, the
.  macro will continue with the Send Message label.)
.
{ON CANCEL}{RETURN CANCEL}~
.
.  (During this part of the macro, if the user presses Cancel, a
.  {RETURN CANCEL} is returned to the higher level.)
.

{RETURN ERROR}
--------------
The {RETURN ERROR} command causes the macro to stop playing the
current level and send an error to the next higher level. See
Levels under Helps and Hints; see also {ON ERROR}.

Since {RETURN ERROR} is the default action when an error occurs
and no {ON ERROR} command is used, the {RETURN ERROR} command is
most often used to reset the {ON ERROR} action to the default
after it has been changed.

Example
In this example, {RETURN ERROR} is used to reset the {ON ERROR}
action to the default.

{ON ERROR}{GO}SendMessage~~
.
.  (During this part of the macro, if an error occurs, the macro
.  will continue with the Send Message label.)
.
{ON ERROR}{RETURN ERROR}~
.
.  (During this part of the macro, if an error occurs, a {RETURN ERROR}
.  is returned to the higher level.)

{RETURN NOT FOUND}
------------------
The {RETURN NOT FOUND} command cancels the current level of the
macro and indicates a search Not Found condition to the next
higher level. {RETURN NOT FOUND} can be used wherever you would
use {RETURN}. See {RETURN}.

Since {RETURN NOT FOUND} is the default action when a Not Found
condition occurs and no {ON NOT FOUND} command is used, the
{RETURN NOT FOUND} command is most often used to reset the
{ON NOT FOUND} action to the default after it has been changed.

Example
In this example, {RETURN NOT FOUND} is used to reset the
{ON NOT FOUND} action to the default.

{ON NOT FOUND}{GO}SendMessage~~
.
.  (During this part of the macro, if a search string is not found,
.  the macro will continue with the Send Message label.)
.
{ON NOT FOUND}{RETURN NOT FOUND}~
.
.  (During this part of the macro, if a search string is not found,
.  a {RETURN ERROR} is returned to the higher level.)
.

{SHELL MACRO}macroname~
-----------------------
The {SHELL MACRO} command plays a Shell macro. Shell macros are
useful when you are switching between various Corel products.

This command is only available if you have Corel Shell version
3.0 or higher. If you have a previous version of Corel Shell,
this command will do nothing.

You do not need to include the .SHM extension in macroname.
However, you must include a path if the Shell macro is in a
directory other than the Keyboard/Macro Files directory
specified in Location of Files. See Location of Files.

Example
You can use the macro in the following example to play a Shell
macro.

{CHAR}answer~DoyouwanttoviewthedrawinginWordPerfect?(y/n)~
  {;}Sendmessagetouserandassignanswertovaranswer~
{IF}"{VARIABLE}answer~"="y"
  {;}Ifvaranswerisy~
{SHELL MACRO}c:\shm\test~
  {;}PlaytheShellmacroTEST.SHM~
{ELSE}
  {;}Otherwise~
{END IF}

{SOUND FILE}filename~
---------------------
The {SOUND FILE} command plays the named sound clip. When the
sound clip has finished, the macro continues. You can enter a
full pathname if you need to.

Example
In the following example, a sound clip is played if the user
chooses to have sound with the presentation.

{CHAR}Answer~Doyouwantsoundwithyourpresentation?(y/n)~
  {;}Prompttheuserforinputandassigntheresponsetovar
     Answer~
{PAUSE}
  {;}Pauseforusertorespond~
{IF}"{VARIABLE}Answer~"="y"~
  {;}Iftheuseranswersyes~
{SOUND FILE}bckgrd08.mid~
  {;}Playthesoundclipbckgrd08.mid~
{END IF}
  {;}Endof{IF}structure~

{SPEED}100ths second~
---------------------
The {SPEED} command slows down the macro. It causes the macro to
pause the amount of time indicated by the 100ths second argument
between each command. This command is useful for debugging
macros.

The default speed is no delay between commands ({SPEED}0~).

Example
For example, if you want your macro to perform a command every
1.5 seconds, insert the following into your macro:

{SPEED}150~

{STATE}
-------
The {STATE} command returns a number representing the current
operational state of Corel Presentations. This lets you create
macros that are aware of the environment in which they are
playing. The operational states and their corresponding code
numbers are listed below.

  3    Current Drawing (only returns a value for drawings
       1 and 2)
  4    Main Drawing Window (not in menus)
  8    Other than Drawing Window
  16   Recording a Macro
  32   Playing a Macro (always set)
  1024 Yes/No Dialog Active
  2048 In a list

State 8 (Other than Drawing Window) refers to any other window.
Playing a Macro (32) is labeled as "always set" because the
{STATE} command is only used in a macro as it is playing.

You can determine what the state of Corel Presentations is by
forming an AND (&) expression with a value called a mask (for
example, {STATE}&3). The result of the operation indicates the
current state of Corel Presentations.

To choose a mask, determine which state(s) you want to check
for. Note the numbers associated with each state and add them
together to calculate the mask value. For example, if you want
to know what drawing you are currently in (1 or 2), the mask
value is 3. If you want to know if you are at the drawing window
(4) and/or if a Yes/No question is active (1024), the mask value
is 1028 (4+1024=1028).

After you have determined the appropriate mask, create an AND
expression, then assign the result to a variable. For example,

{ASSIGN}DocNum~{STATE}&3~
  {;}AssignthecurrentdrawingnumbertovarDocNum~
{ASSIGN}Active~{STATE}&1028~
  {;}Assigntheresult(either4,1024,1028,or0)tovar
     Active~

In this example, the mask values are 3 and 1028. Variable DocNum
contains the current drawing number and variable Active contains
a number that indicates whether the drawing window (4), Yes/No
question (1024), both (1028), or neither (0) are active.

If the result of the AND operation is 0, then the state you were
checking for is not present. If the result is a non-zero number,
then some (or all) of the states you checked for are present.

When {STATE} is performed by itself (not in an expression), it
returns a number that represents the total state of Corel
Presentations. All applicable numbers are added together.

{STEP 1}
--------
The {STEP n} command sets the number of pixels the cursor moves
when you press an arrow key.

The {STEP 1} command sets the number of pixels for each arrow key
movement at 1.

The step that is in effect at the end of your macro remains in
effect in the drawing window after the macro ends. Unless you
want to change the step for the drawing window, you should change
the step back to 1 at the end of any macro that uses a step
command.

Example
{Goto}1.5{Enter}4.25{Enter}
  {;}PositionbeginningofStep1rectangle~
dr
  {;}ChooseRectangleoptionunderDraw~
{STEP 1}
  {;}ChangeStepto1forfirstrectangle~
{Enter}{Up}{Up}{Up}{Up}{Up}{Right}{Right}{Right}{Right}{Right}
{Enter}
  {;}Drawfirstrectangle~
{Goto}2.5{Enter}4.25{Enter}
  {;}PositionbeginningofStep10rectangle~
{STEP 10}
  {;}ChangeStepto10forsecondrectangle~
{Enter}{Up}{Up}{Up}{Up}{Up}{Right}{Right}{Right}{Right}{Right}
{Enter}
  {;}Drawsecondrectangle~
{Goto}4.5{Enter}4.25{Enter}
  {;}PositionbeginningofStep25rectangle~
{STEP 25}
  {;}ChangeStepto25forthirdrectangle~
{Enter}{Up}{Up}{Up}{Up}{Up}{Right}{Right}{Right}{Right}{Right}
{Enter}
  {;}Drawthirdrectangle~

{STEP 10}
---------
The {STEP 10} command sets the number of pixels for each arrow
key movement at 10.

See {STEP 1} for an example of how to use this command.

{STEP 25}
---------
The {STEP 25} command sets the number of pixels for each arrow
key movement at 25.

See {STEP 1} for an example of how to use this command.

{STEP OFF}
----------
The {STEP OFF} command causes the macro to play continuously
after it has been set by the {STEP ON} command to play one step
at a time.

See {STEP ON} for an example of how to use this command.

{STEP ON}
---------
The {STEP ON} command is useful for debugging macros. It causes
the macro to play one step at a time. Between each step, a
message on the status line indicates what the next key or command
is. The key or command is performed when you press any key.

While step is on, if the next step in the macro is a character
(such as A), that character is displayed. If it is a command, one
of the labels listed below, followed by a number, is displayed.

  Label       Meaning
  -----       -------
  ALT X       Alt-letter Macro
  KEY CMD n   Corel Presentations Command, Cursor Control, etc.
  KEY MACRO n Soft Keyboard Macro
  MACRO CMD n Specific Macro Command

The X and n in the table above represent the letter or number
that identifies the specific command of that type. Alt-letter
macro commands are identified by the letter to which they are
assigned. Soft keyboard macro commands are identified by the
number assigned to the macro by the Keyboard Layout feature. See
Keyboard Layout. Variables are identified by name. Keystroke
commands and macro commands are identified by special code
numbers that are listed below.

Keystroke Command Codes (KEY CMD)
  1   ^A
  2   ^B
  3   ^C
  4   ^D
  5   ^E
  6   ^F
  7   ^G
  8   ^H - Home
  9   ^I - Tab
  10  ^J - Enter
  11  ^K - Delete to End of Line
  12  ^L - Delete to End of Page
  13  ^M
  14  ^N
  15  ^O
  16  ^P
  17  ^Q
  18  ^R
  19  ^S
  20  ^T
  21  ^U
  22  ^V
  23  ^W - Up
  24  ^X - Right
  25  ^Y - Left
  26  ^Z - Down
  27  ^[ - Escape
  28  ^\
  29  ^]
  33  Search
  34  Help
  35  Indent
  36  List Files
  37  Bold
  38  Exit
  39  Underline
  40  ReDraw
  41  Save
  44  Setup
  45  Search Left
  46  Switch
  47  Left/Right Indent
  48  Date/Outline
  49  Center
  50  Print
  51  Format
  52  Front
  53  Retrieve
  57  Replace
  58  Position Display
  59  Block
  60  Zoom Area
  61  Flush Right
  62  Grid Display
  64  Back
  65  Macro
  68  Shell
  69  Spell
  70  Redraw
  71  Move
  72  Export
  73  Tab Align
  74  Grid Snap
  75  Font
  76  Duplicate
  77  Macro Define
  80  Backspace
  81  Delete Right
  83  Word Right
  84  Word Left
  85  Home, Home, Right (by pressing end key)
  88  GoTo (Ctrl-Home)
  89  PgUp
  90  PgDn
  91  Screen Down (by hitting "+" on numeric keypad)
  92  Screen Up (by pressing "-" on numeric keypad)
  93  Typeover
  94  Left Margin Release (reverse tab)
  95  Hard Page (Ctrl+Enter)
  96  Soft Hyphen (Ctrl+-)
  97  Hyphen
  98  Required (Hard) Space (Home,Space Bar)
  107 Menu Bar (Alt-=)
  108 Paste
  109 Cut
  110 Copy

Macro Command Codes (MACRO CMD)
  1   {ASSIGN}
  2   {BELL}
  3   {BREAK}
  4   {CALL}
  5   {CANCEL OFF}
  6   {CANCEL ON}
  7   {CASE}
  8   {CASE CALL}
  9   {CHAIN}
  10  {CHAR}
  11  {;} (comment)
  14  {ELSE}
  15  {END FOR}
  16  {END IF}
  17  {END WHILE}
  18  {FOR}
  19  {FOR EACH}
  20  {GO}
  21  {IF}
  22  {LABEL}
  23  {LOOK}
  24  {NEST}
  25  {NEXT}
  26  {SHELL MACRO}
  27  {ON CANCEL}
  28  {ON ERROR}
  29  {ON NOT FOUND}
  30  {PAUSE}
  32  {QUIT}
  33  {RESTART}
  34  {RETURN}
  35  {RETURN CANCEL}
  36  {RETURN ERROR}
  37  {RETURN NOT FOUND}
  38  {SPEED}
  39  {STEP ON}
  40  {TEXT}
  41  {STATE}
  42  {WAIT}
  43  {WHILE}
  44  {Macro Commands}
  45  {STEP OFF}
  46  {ORIGINAL KEY}
  47  {IF EXISTS}
  52  {VARIABLE}
  53  {SYSTEM}
  54  {MID}
  55  {NTOK}
  56  {KTON}
  57  {LEN}
  58  {~} (hard tilde)
  59  {PAUSE KEY}
  257 {STEP 1}
  258 {STEP 10}
  259 {STEP 25}
  260 {CONTROL}
  261 {DIALOG}
  262 {DIALOGMSG}
  263 {ENDDIALOG}
  264 {SOUND FILE}

The {STEP ON} feature is particularly useful when you want to
track the contents of a variable. When a variable is encountered
with Step on, MACRO CMD 56 (for {VARIABLE}) is first displayed,
then each letter of the variable name is displayed. Then the
variable's contents (if they exist) are displayed one character
at a time. For example, if variable Num contains 14, the first
message, MACRO CMD 56, is followed by an N, then a u, then an m,
then a tilde (~), which are then followed by a 1, then a 4.

Note that, if the variable was entered as {VAR #}, VAR # is
displayed instead of MACRO CMD 56. The contents are then
displayed one character at a time as usual.

While the macro is playing, press Exit (F7) to turn off Step
mode. Pressing Cancel (Esc) ends the macro unless Cancel is
turned off or is redefined. See {CANCEL OFF} and {ON CANCEL}.

Example
The following example shows how you can use {STEP ON} and
{STEP OFF} to isolate problems in a macro.

.
.  (This section will play normally.)
.
{STEP ON}
.
.  (This section will play one keystroke at a time.)
.
{STEP OFF}
.
.  (This section will play normally.)
.

{SYSTEM}sysvar~
---------------
The {SYSTEM} command returns the value of the given system
variable. These system variables allow the macro to be aware of
the current state of Corel Presentations. You can use mask values
to check for multiple system variables. See {STATE} for
information on masking. Valid system variables are listed below.

Rather than using the name of the system variable in the {SYSTEM}
command, you can use the number given in parentheses next to each
system variable name below. Using the number instead of the name
is especially useful when you want to use the same macro in
different international versions of Corel Presentations.

Example
In the example below, the macro checks to see if the drawing has
been modified. If the drawing has not been modified, the macro
exits the drawing without saving it.

{ASSIGN}state~{SYSTEM}4~~
  {;}Checktoseehowmanyitemsareinthecurrentlistand
     assignthesystemvaluetovariablestate~
{IF}{VARIABLE}state~=0~
  {;}Iftherearenoitemsinthelist~
{Exit}nn
  {;}ExitthedrawingwithoutsavingbutdonotexitCorel
     Presentations~
{END IF}

SysVar          Value(s) Returned
------          -----------------
Drawing (1)     0  Current drawing or slide show has not been
                   modified
                1  Current drawing or slide show has been
                   modified
X-Position (2)  Horizontal position of the mouse pointer in
                1200ths of an inch, as long as the pointer is in
                the main drawing area.
Y-Position (3)  Vertical position of the mouse pointer in 1200ths
                of an inch, as long as the pointer is in the main
                drawing area.
List (4)        0     No items in the list
                #     Number of items in the list
                65535 Not in a list
Mode (6)        0  No dialog active
                1  Dialog active
                2  In Slide Show mode
                4  In Charting mode
                8  In Bitmap mode
                16 In Text mode
                32 Grid Snap is on
                64 Item(s) selected
Name (10)       Name of the current drawing or slide show (for
                example, DUCK.WPG or TUTORIAL.SHW).
Path (11)       Path to the current drawing or slide show (for
                example, C:\COREL\PR21\ or D:\FIGURES\).

Note that the Mode values are additive. For example, if you are
editing a text area in Slide Show mode, an 18 will be returned.
Similarly, if you are editing a text line in the Base Font
dialog box while in Slide Show mode, a 19 will be returned.

{TEXT}var~message~
------------------
The {TEXT} command prompts the user by displaying a message on
the status line, then pauses until the user presses Enter.
The input (as many as 129 keystrokes) from the user is then
assigned to the variable. See Prompting and User Input under
Helps and Hints for additional methods of obtaining user input.

See {BELL} and {IF EXISTS} for examples of how to use this
command.

{VARIABLE}var~
--------------
This command performs or writes out the contents of a variable.

After a value has been assigned to a variable, the {VARIABLE}var~
command can be placed anywhere you would normally place the
variable contents. It can be placed as an argument for another
command, or by itself.

A variable can hold no more than 129 keystrokes (characters).

See {ASSIGN} and {CASE} for examples of how to use this command.

{WAIT}10ths second~
-------------------
The {WAIT} command pauses the macro for the indicated time.

{WHILE}expr~
------------
While the expression expr is true, the commands between the
{WHILE} and the {END WHILE} are repeated. This command is like
the {FOR} command, except that it does not increase the value of
a variable each time through the loop. To end the loop, use
another command that will force the expression to be false. See
Loops under Helps and Hints.

Remember that if you use a variable in expr, the variable must
already exist before the {WHILE} command is executed.

Example
In this example, the message "Counting" will be displayed until
variable "Count" reaches 50.

{ASSIGN}Count~0~
  {;}InitializevarCount.(Thiscommandcreatesthevariable,
     thenassignsit"0")~
{WHILE}{VARIABLE}Count~<50~
{TEXT}var~Counting~
  {;}Sendtheprompt"Counting".~
{ASSIGN}Count~{VARIABLE}Count~+1~
  {;}IncreasevarCountby1eachtimethroughtheloop~
{END WHILE}


HELPS AND HINTS
===============

Chaining and Nesting
--------------------
Chaining a macro file causes the named file to play as soon as
the current file ends. A file can use only one chain command. If
you include more than one chain command, the last one encountered
during the macro will be the only one performed.

Nesting is the process of playing another macro file within a
parent file. The parent file continues with the command directly
after the nest command when the nested file ends.

Nesting a macro is similar to calling a subroutine, except that
the nested macro is not a part of the calling macro. See
Subroutines. It is a separate macro, referenced by giving the
macro name (or the full pathname if it is not in the
Keyboard/Macro Files directory currently specified in Location
of Files). You do not need to include the .PRM extension in the
filename or pathname. Because the parent file automatically
continues when the nested macro has finished, you do not need to
place a {RETURN} command at the end of a nested macro.

If there are certain procedures that you frequently use in your
macros, you can put them in smaller macros and nest them when
needed.

You can nest macro files several levels deep. See Levels. The
main file nests a second file; the second file nests a third.
After the third file has finished, the rest of the second file
plays. After the second file has finished, the remaining part of
the main file plays.

Commenting Out
--------------
You can use the {;} command to comment out sections of a macro
that you don't want to play. This practice is useful for testing
and debugging your macros.

Anything (including commands) between the {;} command and the
next tilde is ignored as the macro plays. It is easy to comment
out commands such as {NEST}, {CHAIN}, and so on, where there is
only one tilde associated with the command:

  {;}{NEST}thefile~

However, if the commands to be commented out have more than one
tilde, you must insert a {;} to correspond to each tilde:

  {;}{ASSIGN}Number~{;}45~

When multiple tildes are involved, you may find it easier to
delete the additional tildes in the section to be commented out
so that you only have to use one {;} command. You will have to
re-insert the tildes if you later decide to restore the section.

Levels
------
In a macro, you can have as many as 30 levels. Each {NEST}
command uses two levels (one for executing the macro and one for
a possible CHAIN command). Each {CALL}, {CASE CALL}, nested {IF},
{FOR}, {FOR EACH}, or {WHILE} command uses one level.

Macro levels are maintained in stacks. Levels in expressions are
maintained in a separate stack from macro levels, so expressions
are not counted in the 30-level limit. Generally, expressions
use one level, but may use more if they are very complex.

Loops
-----
Whenever the same commands repeat several times, that section of
the macro is called a loop. For example,

{LABEL}Top~
  {;}Topoftheloop~
endlessloop
  {;}Type"endlessloop"~
{GO}Top~
  {;}Gototop~

In this example, the words "endless loop" are written
continuously to the screen (if you are in text mode). There is
no way to stop the macro without pressing Cancel (Esc) or
Ctrl-Break. When you create a loop, it is very important to have
a way for the loop to end. In the following example, a count is
kept of the number of times the text has been written to the
screen. After the tenth time, the loop ends.

{ASSIGN}Counter~0~
  {;}Assign0tovarCounter~
{LABEL}Top~
  {;}Topoftheloop~
{ASSIGN}Counter~{VARIABLE}Counter~+1~
  {;}Add1tovarCounter~
Loop{VARIABLE}Counter~{Enter}
  {;}Type"Loop"#~
{IF}{VARIABLE}Counter~=10~
  {;}Ifthisisthetenthtime~
{QUIT}
  {;}Quitthemacro~
{ELSE}
  {;}Otherwise,~
{GO}Top~
  {;}Gototop(repeattheloop)~
{END IF}
  {;}Endof{IF}structure~

There are many types of loops you can create with macro commands.
You can use an IF structure as in the above examples, or you can
use the {FOR}, {FOR EACH}, or {WHILE} commands (see each command
above). You can also create loops by going to or calling
subroutines (with the {GO} or {CALL} command). The structure you
should use for any given loop will depend on the task you are
trying to accomplish.

Message Display
---------------
The {CHAR}, {CONTROL}, {DIALOG}, {DIALOGMSG}, and {TEXT} commands
send a message to the screen.

Prompting and User Input
------------------------
The following commands can be used to prompt the user of your
macro, and/or obtain input from the user:

{CHAR}
{CONTROL}
{DIALOG}
{DIALOGMSG}
{LOOK}
{PAUSE}
{PAUSE KEY}
{TEXT}

These commands are similar to each other in some ways, yet
different in others. Comparisons are based on the following
features of each command:

*  Whether a message is sent with the command or command
   combination.
*  If a message is sent, whether the message remains on the
   screen until 1) the screen is rewritten or the message is
   overwritten with a new command, 2) input is finished, or
   3) you exit Corel Presentations or the message is overwritten
   with a new command.
*  Whether the macro pauses at the command or command combination
   for user input.
*  If the macro pauses for input, whether the input goes directly
   into the drawing or into a variable.
*  If the macro pauses for input, the method of terminating
   input.

Subroutines
-----------
A subroutine is a set of commands you may want to repeat several
times in a macro. Instead of repeating the commands each time you
need them, you can include them only once, then play that part of
the macro each time you want the commands performed. Inserting a
call to a subroutine functions as if its commands were placed at
each point of call. There is no limit to the number of
subroutines you can have in a macro file.

A subroutine is identified by two commands. The first command,
{LABEL}, marks the beginning of a subroutine. The second command,
{RETURN}, marks the end.

If the commands in the subroutine guarantee correct branching or
returning, you do not need a {RETURN} at the end of the
subroutine.

You can use the following commands to play a subroutine:

{CALL}
{CASE}
{CASE CALL}
{GO}
{ON CANCEL}
{ON ERROR}

Since there may be more than one subroutine in a macro, the
first seven letters of the name associated with each one must
be unique. The label name must be entered as an argument in the
command that activates the subroutine, and must match the name
following the {LABEL} command identifying the beginning of the
subroutine.


TROUBLESHOOTING
===============
If you have trouble getting a macro to work, check to see that
you have not made one of the errors listed below.

General Errors
--------------
See the descriptions of the commands you are using and Advanced
Macro Expressions for information on correcting these errors.

*  You have used the wrong number of tildes or have put them in
   the wrong places.
*  You have entered commands incorrectly.
*  You are performing a numeric operation on a string. This
   usually happens when you use an invalid character (such as a
   space, period, or comma) in an expression that is assigned to
   a variable.
*  You are trying to write text to the drawing window without
   first entering the text editor. If this happens, the letters
   in your text will try to access the pull-down menus.

Errors in Variables
-------------------
See Advanced Macro Variables for information on correcting these
errors.

*  You are using a variable name instead of the {VARIABLE}var~
   command, or vice versa.
*  You have misspelled a variable name.
*  You are trying to access nonexistent variables.

Errors in Subroutines and Loops
-------------------------------
See Levels, Loops, and Subroutines for information on correcting
these errors.

*  You have created an infinite loop.
*  A {RETURN} is missing from the end of a subroutine.
*  Label names are misspelled.
*  You are going to or calling nonexistent labels.
*  You are nesting files too many deep or using too many levels.
   You can have as many as 30 files or levels.
*  Commands that end a loop (such as {END FOR}, {END IF}, and
   {END WHILE}) are missing.


ADVANCED MACRO VARIABLES
========================

A variable represents a place in memory where data is stored
like a file in a cabinet or a letter in a mailbox. As its name
indicates, the data in a variable is changeable. You might want
to use variables to calculate and keep track of values and text
that change while a macro plays.

Corel Presentations uses variables that you create and name, and
whose contents you determine. You can perform operations on these
variables to change their contents.

Corel Presentations variables are accessible from anywhere inside
a macro. In other words, they are global variables.

Naming Variables
----------------
Each variable must have a unique name by which you refer to them.
The name may consist of any combination of the characters in the
Corel WordPerfect character sets. However, only the first seven
letters are used to determine uniqueness. So, Corel Presentations
considers ABCDEFG and ABCDEFGH to refer to the same variable.

Variable names are not case sensitive. Corel Presentations
considers Abc, AbC, ABC, and abc to be the same.

Variables receive their names when the variables are assigned.
See Assigning Variables for more information.

Variable Contents
-----------------
Variables can contain text, numbers, and keystrokes. The method
you use to assign variables may affect the kinds of commands and
keystrokes that can be assigned to a variable. A variable can
hold as many as 129 keystrokes. A keystroke can be a character,
an extended character, a keystroke command, or a programming
command.

Variables are written out as keystrokes. Therefore, if you assign
keystroke commands (such as {Up}, {Down}, {Left}, {Right}, and
{Enter}) to a variable, and then write out the variable, the
keystrokes are performed.

Assigning Variables
-------------------
You frequently assign a variable with the {ASSIGN} command. For
example, the following statement assigns a variable:

  {ASSIGN}Number~45~

The {ASSIGN} command creates a variable named "Number" and puts
in "45" as its contents. See the description of the {ASSIGN}
command in Advanced Macro Programming Commands. See Inserting
Commands under Macros: Edit in the Corel Presentations Reference
manual for information on inserting the {ASSIGN} command.

The following commands also assign variables:

{CHAR}
{CONTROL}
{DIALOG}
{FOR}
{FOR EACH}
{LOOK}
{TEXT}

See Advanced Macro Programming Commands for a description of each
of these commands.

Writing Out Variables
---------------------
You can write out a variable anywhere you would want its
contents. For example, by writing out a variable you can do the
following tasks:

*  Use the contents of the variable as a subroutine.
*  Insert the contents as text in a text area or text line.
*  Provide variable arguments in other programming commands.

To write out a variable from within a macro, use the {VARIABLE}
command in the Edit Macro dialog box. For example, the statement
{VARIABLE}Number~ would execute the variable named "Number." If a
variable is named with a single-digit number (1, 2, 3, 4, 5, 6,
7, 8, 9, or 0), you can write out the variable by choosing Key
Commands (Ctrl+V), then pressing Alt+#, where # is the number of
the variable. The command that is inserted appears as {VAR #},
and is equivalent to {VARIABLE}#~.

Another advantage of naming variables with a single digit is
that you can write them out from the drawing window. For example,
if you are in the drawing window and want to know the current
contents of variable 5, press Alt+5. You cannot use this method
to write out variables named in other ways.

Important:  When you write text to the drawing window, the text
must either be part of a message (such as {TEXT}), or the Text
Editor must be active. If you try to write text to the drawing
window from a variable when the Text Editor is inactive, the
characters you type will access the pull-down menus.

Variable Duration
-----------------
The contents of variables remain in memory until you exit Corel
Presentations, not just until the macro ends.

If you want to erase a variable, use the following command:
{ASSIGN}var~~. This command not only empties the variable of its
contents, but also releases the memory used by the variable.
After this command, the variable no longer exists. It is a good
idea to empty variables at the beginning of a macro in which they
are used (unless the macro assigns new contents to them) to
insure that the variables do not contain values from previous
macros.
